package com.youyi.yypermissionlibrary.core;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.PermissionChecker;
import android.util.Log;

/* access modifiers changed from: package-private */
public final class AcpService {
    private static final String TAG = "AcpService";

    private AcpService() {
    }

    static int checkSelfPermission(Context context, String str) {
        try {
            int i = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.targetSdkVersion;
            if (Build.VERSION.SDK_INT >= 23) {
                if (i < 23) {
                    return PermissionChecker.checkSelfPermission(context, str);
                }
                Log.i(TAG, "targetSdkVersion >= Build.VERSION_CODES.M");
                return ContextCompat.checkSelfPermission(context, str);
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return ContextCompat.checkSelfPermission(context, str);
    }

    static void requestPermissions(Activity activity, String[] strArr, int i) {
        ActivityCompat.requestPermissions(activity, strArr, i);
    }

    static boolean shouldShowRequestPermissionRationale(Activity activity, String str) {
        boolean shouldShowRequestPermissionRationale = ActivityCompat.shouldShowRequestPermissionRationale(activity, str);
        Log.i(TAG, "shouldShowRational = " + shouldShowRequestPermissionRationale);
        return shouldShowRequestPermissionRationale;
    }
}
